package net.qiqbframework.lifecycle;

import net.qiqbframework.common.ImmutableException;

import java.lang.reflect.Method;

/**
 * 生命周期处理调用异常
 */
public class LifecycleHandlerInvocationException extends ImmutableException {

    private static final String DEFAULT_FAILURE_MESSAGE = "Failed during invocation of lifecycle handler [%s] on component [%s]";

    public LifecycleHandlerInvocationException(String message) {
        super(message);
    }

    public LifecycleHandlerInvocationException(Method lifecycleHandler, Object lifecycleComponent, Throwable cause) {
        this(DEFAULT_FAILURE_MESSAGE.formatted(lifecycleHandler, lifecycleComponent), cause);
    }

    public LifecycleHandlerInvocationException(String message, Throwable cause) {
        super(message, cause);
    }
}
